package linwen.wang.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import linwen.wang.shop.entity.Order;
import linwen.wang.shop.entity.User;
import linwen.wang.shop.mapper.OrderMapper;
import linwen.wang.shop.service.OrderService;
import linwen.wang.shop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
    @Autowired
    private UserService userService;

    @Override
    @Transactional(readOnly = true)
    public Order findOrderById(Long orderId) {
        Order order = this.getById(orderId);
        User user = userService.getById(order.getUserId());
        order.setUser(user);
        return order;
    }
}
